#ifndef __RTC_8025T_H
#define __RTC_8025T_H

#include "hc32f460.h"
#include "dev_i2c.h"
#include "CommFunc_API.h"


#define RTC_WRITE       0x64
#define RTC_READ        0x65

#define RTC8025T_SCL    GET_PIN(E, 11)
#define RTC8025T_SDA    GET_PIN(E, 12)
            
#pragma pack(1)
typedef struct //Extension_Register
{
	unsigned char SS;/*秒*/
	unsigned char NN;/*分*/
	unsigned char HH;/*时*/
	unsigned char WW;/*星期*/
	unsigned char DD;/*日*/
	unsigned char MM;/*月*/
	unsigned char YY;/*年*/	
}_mRTC;	

//定义实时时钟结构 698协议中 date_time_s 就是这种结构 要求年是word，但长度为7个字节
typedef struct TRealTimer_t
{
	//年
	uint16_t wYear;
	//月
	uint8_t Mon;
	//日
	uint8_t Day;
	//时
	uint8_t Hour;
	//分
	uint8_t Min;
	//秒
	uint8_t Sec;

}TRealTimer;
#pragma pack()
typedef union //Extension_Register
{
	_mRTC	Detail;
	unsigned char All[7];
}_mRTC_U;


extern _mRTC_U now;
extern TRealTimer RealTimer;
extern struct rt_i2c_bus_device *RTC_8025Tdev;
extern void RTC_8025T_thread_entry(void *parameter);

void RTC_8025T_Read(struct rt_i2c_bus_device *i2c_bus, rt_uint8_t *read_buf, rt_uint32_t Rev_num );
void RTC_8025T_Write(struct rt_i2c_bus_device *i2c_bus, rt_uint8_t *buf, rt_uint32_t num );
void RTC_8025T_init();
#endif